<template>
	<view class="container">
		<uni-list v-if="this.user != null">
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'auth-filled'}" title="学号" :rightText="user.sno" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="姓名"
				:rightText="user.name" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'calendar-filled'}" title="学年"
				:rightText="user.schoolYear" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'phone-filled'}" title="手机号码"
				:rightText="user.phone" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'email-filled'}" title="邮箱" :rightText="user.mail" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'map-filled'}" title="住址"
				:rightText="user.location" />
		</uni-list>
		<uni-list v-if="this.trUser != null">
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'person-filled'}" title="用户名"
				:rightText="trUser.userName" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'gear'}" title="部门" :rightText="trUser.dept.deptName" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'phone-filled'}" title="手机号码"
				:rightText="trUser.phonenumber == '' ? '无数据':trUser.phonenumber" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'email'}" title="邮箱"
				:rightText="trUser.email == '' ? '无数据':trUser.email" />
			<uni-list-item showExtraIcon="true" :extraIcon="{type: 'gear'}" title="登陆时间"
				:rightText="trUser.loginDate" />
		</uni-list>
	</view>
</template>

<script>
	import {
		getUserProfile
	} from "@/api/system/user"
	import {
		getUser,
		getLoginPeople
	} from '@/utils/auth'

	export default {
		data() {
			return {
				user: null,
				trUser: null,
				roleGroup: "",
				postGroup: ""
			}
		},
		onLoad() {
			this.getUser()
		},
		methods: {
			getUser() {
				if (getLoginPeople() == "Teacher") {
					this.trUser = getUser();
					// console.log(this.trUser)
				} else {
					getUserProfile().then(response => {
						this.user = response.data
						this.user.sno = String(response.data.sno);
						this.user.schoolYear = String(response.data.schoolYear);
						this.roleGroup = response.roleGroup
						this.postGroup = response.postGroup
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}
</style>